<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('tourtypes_dropdown'))
{
	function tourtypes_dropdown($tourtypes, $selected = null, $showAll = false, $showNights = true)
	{
		$d = "<select name=\"tourtype\" id=\"tourtype\">\n";
		
		if ($showAll)
		{
			$d .= "\t<option value=\"0\">All Tour Types</option>\n";
		}
		
		for ($i = 0; $i < count($tourtypes); $i++)
		{
			if (($selected == $tourtypes[$i]['id']) || (isset($_POST['tourtype']) && $_POST['tourtype'] == $tourtypes[$i]['id']))
			{
				$s = ' selected="selected"';
			} else
			{
				$s = '';
			}
			
			if ($showNights)
			{
				if ($tourtypes[$i]['tour_nights'] > 1)
				{
					$nights = ' nights';
				} else
				{
					$nights = ' night';
				}
				
				$d .= "\t<option value=\"" . $tourtypes[$i]['id'] . "\"" . $s . ">" . $tourtypes[$i]['tour_name'] . " - " . $tourtypes[$i]['tour_nights'] . $nights . "</option>\n";
			} else
			{
				$d .= "\t<option value=\"" . $tourtypes[$i]['id'] . "\"" . $s . ">" . $tourtypes[$i]['tour_name'] . "</option>\n";
			}
		}
			
		
		$d .= "</select>";
		return $d;
	}
}

?>